home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_9.lha / 7_9 / 7_9_getn.c < prev    next >
Text File  |  1993-08-08  |  535b  |  35 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Get the next entry from a list,
  6. / removing it afterwards.
  7. / curr is left alone.
  8. nt dlist::getnext(dlink *&a)
  9.  
  10.    if (!last)
  11. return 0;
  12.  
  13.    // choose the link to remove
  14.    if (curr)
  15.        if (curr == last)
  16.     {
  17.     curr = 0;
  18.     return 0;
  19.     }
  20.  
  21. else
  22.     a = curr->next;
  23.  
  24.    else
  25. a = last->next;
  26.  
  27.    // remove a from the list
  28.    if (a == last)
  29. last = 0;
  30.  
  31.    else
  32. a->remove();
  33.    return 1;
  34.  
  35.